package cn.csust.net2.manager.client.panel;

import cn.csust.net2.manager.client.ux.BeanGridPanel;
import cn.csust.net2.manager.shared.po.Article;
import cn.csust.net2.manager.shared.po.Issue;
import cn.csust.net2.manager.shared.po.TeacherReward;
import cn.csust.net2.manager.shared.service.TeacherInformationService;
import cn.csust.net2.manager.shared.service.TeacherInformationServiceAsync;

import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.TabPanel.TabPosition;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Element;

public class TeacherInformationPanel extends ContentPanel{
	private TabPanel tabPanel;
	private TabItem teacherInfoTabItem;
	private TabItem workSituationTabItem;
	private TabItem rewardTabItem;
	private TabItem issueTabItem;
	protected TeacherInformationServiceAsync service;
	@SuppressWarnings("unused")
	private BeanGridPanel<Article> articleGridPanel;
	@SuppressWarnings("unused")
	private BeanGridPanel<Issue> issueGridPanel;

	@SuppressWarnings("unused")
	private ContentPanel issueContentPanel;
//	private FormPanel issueFormPanel;
	private BeanGridPanel<TeacherReward> teacherRewardGridPanel;
	
	public TeacherInformationPanel() {
		service = GWT.create(TeacherInformationService.class);
		setHeaderVisible(false);
		create();
	}
	
	@Override
	protected void onRender(Element parent, int pos) {
		// TODO Auto-generated method stub
		super.onRender(parent, pos);
		this.setLayout(new FitLayout());	
	}
	
	public void create() {
		tabPanel = new TabPanel();
		tabPanel.setTabPosition(TabPosition.BOTTOM); 

		workSituationTabItem = new TabItem("工作情况");
		workSituationTabItem.setLayout(new FitLayout());
		workSituationTabItem.add(new WorkSituationPanel(service));
		tabPanel.add(workSituationTabItem);
		
		teacherInfoTabItem = new TabItem("教师基本信息");
		teacherInfoTabItem.setLayout(new FitLayout());
		teacherInfoTabItem.add(new TeacherRegisterPanel());
		tabPanel.add(teacherInfoTabItem);
		
		rewardTabItem = new TabItem("获奖情况");
		rewardTabItem.setLayout(new FitLayout());
		teacherRewardGridPanel = new BeanGridPanel<TeacherReward>(new TeacherReward(),service);
		teacherRewardGridPanel.createDefault();
		rewardTabItem.add(teacherRewardGridPanel);
		tabPanel.add(rewardTabItem);
		
		issueTabItem = new TabItem("科研情况");
		issueTabItem.setLayout(new FitLayout());
//		createIssueContentPanel();
		issueTabItem.add(new IssuePanel(service));
		tabPanel.add(issueTabItem);
		
		this.add(tabPanel);
	}
	
//	public void createIssueContentPanel() {
//		issueContentPanel = new ContentPanel();
//		issueContentPanel.setHeaderVisible(false);
//		issueContentPanel.setScrollMode(Scroll.AUTO);
//		
//		issueFormPanel = new FormPanel();
//		issueFormPanel.setFrame(true);
//		issueFormPanel.setHeaderVisible(false);
//		issueFormPanel.setWidth("100%");
//		issueFormPanel.setLayout(new FlowLayout());
//		
//		issueFormPanel.add(createFieldSetArticle());
//		issueFormPanel.add(createFieldSetIssue());
//		
//		issueContentPanel.add(issueFormPanel);
//	}
//	
//	public FieldSet createFieldSetArticle() {
//		FieldSet fieldSetArticle = new FieldSet();
//		fieldSetArticle.setHeading("发表文章");
//		fieldSetArticle.setCollapsible(true);
//		fieldSetArticle.setLayout(new FitLayout());
//
//		articleGridPanel = new BeanGridPanel<Article>(Article.class);
//		articleGridPanel.setDatabase(false);
//		articleGridPanel.setSaveButton(false);
//		articleGridPanel.setPagingToolBar(false);
//		
//		articleGridPanel.createDefault();
//		
//		fieldSetArticle.add(articleGridPanel);
//		return fieldSetArticle;
//	}
//	
//	public FieldSet createFieldSetIssue() {
//		FieldSet fieldSetIssue = new FieldSet();
//		fieldSetIssue.setHeading("参与课题");
//		fieldSetIssue.setCollapsible(true);
//		fieldSetIssue.setLayout(new FitLayout());
//
//		issueGridPanel = new BeanGridPanel<Issue>(Issue.class);
//		issueGridPanel.setDatabase(false);
//		issueGridPanel.setSaveButton(false);
//		issueGridPanel.setPagingToolBar(false);
//		
//		issueGridPanel.createDefault();
//		
//		fieldSetIssue.add(issueGridPanel);
//		return fieldSetIssue;
//	}

}
